#!/usr/bin/python

from pylab import *
import sys
import os
# appends project's (maloqp) parent directory to python search path
sys.path.append(os.getcwd().rsplit(os.path.sep, 2)[0])

import maloqp.src.angle as angle



cutoffs = ['0', '0.5', '1', '1.5', '2', \
          '2.5', '3', '3.5', '4', '4.5', \
          '5', '5.5', '6', '6.5', '7', '7.5',\
          '8', '8.5', '9', '9.5', '10']

x = [-1*float(y) for y in cutoffs]

ma = [0 for y in cutoffs]
lo = [0 for y in cutoffs]
qp = [0 for y in cutoffs]

no_of_samples = '200'
sample = 'bmmatrix'
lowest = 'bmlowest'

## for i in xrange(len(cutoffs)):
##     file1 = "../data/"+sample+"/s"+cutoffs[i]
##     file2 = "../data/"+sample+"/ma"+cutoffs[i]
##     file3 = "../data/"+sample+"/lo"+cutoffs[i]
##     file4 = "../data/"+sample+"/qp"+cutoffs[i]
##     ma[i] += mcc.mcc(file1, file2)
##     lo[i] += mcc.mcc(file1, file3)
##     qp[i] += mcc.mcc(file1, file4)

for i in xrange(len(cutoffs)):
    for t in ['1', '2', '3']:
        file = "../data/real_wyk"
        file2a = "../data/"+lowest+"/ma"+cutoffs[i]+'_'+no_of_samples+'_'+t
        file3a = "../data/"+lowest+"/lo"+cutoffs[i]+'_'+no_of_samples+'_'+t
        file4a = "../data/"+lowest+"/qp"+cutoffs[i]+'_'+no_of_samples+'_'+t
        ma[i] += angle.main([file, file2a])
        lo[i] += angle.main([file, file3a])
        qp[i] += angle.main([file, file4a])

for i in xrange(len(cutoffs)):
    ma[i] /= 3
    lo[i] /= 3
    qp[i] /= 3

print qp
print lo
print ma

plot(x, qp, 'r-^', linewidth=2)
plot(x, lo, 'b-s', linewidth=2)
plot(x, ma, 'y-o', linewidth=2)

#axis([-10, 0, 0, 1])

legend(('Quadratic Programming', 'Log-Odds', 'Match'),loc='lower right')
xlabel('Energy')
ylabel('Angle (in degrees)')
title('True Matrix and Lowest Scoring Seq: BM - 200')
grid(True)
savefig('model-lowest-true-bm')
show()
